index.spec.js ➔ ???   B
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
c 0
b 0
f 0
nc 2
dl 0
loc 27
rs 8.8571
nop 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.spec.js ➔ ... ➔ ??? 0 1 1
1
// spec/index.spec.js
2
"use strict";
3
4
// :: DEPENDENCIES
5
6
// load native dependencies
7
const path = require("path");
8
9
// load local dependencies
10
const root       = path.dirname(__dirname);
11
const ejsception = require(path.join(root, "index.js"));
12
const Throwable  = require(path.join(root, "Throwable.js"));
13
const Exception  = require(path.join(root, "Exception.js"));
14
15
// All accessible 'classes'
16
const classes = [
17
    "Throwable",
18
        "Exception"
19
];
20
21
// wrap them in a plain object
22
const local = {
23
    Throwable,
24
        Exception
25
};
26
27
// :: TESTING
28
29
// test the module
30
describe("ejsception | @egalabs/exception", () => {
31
32
    // :: VARIABLES
33
34
    let key;
35
    const test = (() => ejsception[key] = 0);
36
    const suite = (() => {
37
        expect(ejsception[key]).toEqual(local[key]);
38
        expect(ejsception[key].prototype).toEqual(local[key].prototype);
39
    });
40
41
    // :: TESTING
42
43
    it("should me immutable", () => {
44
        for (let i = 0; i < classes.length; i += 1) {
45
            key = classes[i];
46
            expect(test).toThrowErrorOfType("TypeError");
47
        }
48
    });
49
50
    // test all 'classes'
51
    for (let i = 0; i < classes.length; i += 1) {
52
        key = classes[i];
53
        it("should have a " + key + " 'class'", suite);
54
    }
55
56
});